﻿using SharpDX;
using SharpDX.Direct3D11;
using SharpDX.DXGI;
using SharpDX.Toolkit.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;

namespace Bikiball.Graphic.Vextex
{
    [StructLayout(LayoutKind.Sequential)]
    public struct VertexPositionTexture3D : IEquatable<VertexPositionTexture3D>
    {
        [VertexElement("SV_Position",Format.R32G32B32_Float)]
        public Vector3 Position;
        [VertexElement("TEXCOORD", 0, Format.R32G32B32_Float)]
        public Vector3 TextureCoordinate;

        public VertexPositionTexture3D(Vector3 position, Vector3 textureCoordinate)
            : this()
        {
            Position = position;
            TextureCoordinate = textureCoordinate;
        }

        /// <summary>
        /// Defines structure byte size.
        /// </summary>
        public static readonly int Size = 24;

        public bool Equals(VertexPositionTexture3D other)
        {
            return Position.Equals(other.Position) && TextureCoordinate.Equals(other.TextureCoordinate);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            return obj is VertexPositionTexture3D && Equals((VertexPositionTexture3D)obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                int hashCode = Position.GetHashCode();
                hashCode = (hashCode * 397) ^ Position.GetHashCode();
                hashCode = (hashCode * 397) ^ TextureCoordinate.GetHashCode();
                return hashCode;
            }
        }

        public static bool operator ==(VertexPositionTexture3D left, VertexPositionTexture3D right)
        {
            return left.Equals(right);
        }

        public static bool operator !=(VertexPositionTexture3D left, VertexPositionTexture3D right)
        {
            return !left.Equals(right);
        }

        public override string ToString()
        {
            return string.Format("Position: {0}, Texcoord: {2}", Position, TextureCoordinate);
        }
    }
}
